#ifndef  __L_
#define  __L_
#include <func.h>
#define MAXEVENTS 12
#define BUFSIZE 1024
typedef struct channel{
    char sendbuf[BUFSIZE];
    int sendbufsize;
    char recvbuf[BUFSIZE];
    int recvbufsize;
    int fd;
}channel_t;

typedef struct pthread{
    int flag;
    int clientfd;
    char* filename;
    char* order;
    int epfd;
}pthreadpoll_t;
int tcpinit(u_int16_t port,const char* ip);
void epollinit(int epfd,int fd);
void channelsinit(channel_t channels[],int max);
void addepollread(int epfd,int fd);
void addepollwrite(int epfd,int fd);
void delepollwrite(int epfd,int fd);
void addchannel(channel_t channels[],int max,int fd);
int addaccept(int fd);
int getchannelsevent(channel_t channels[],int max,int fd);
void delepollfd(int epfd,int fd);
void delchannel(channel_t channels[],int max,int fd);
void clearrecvbuf(channel_t *channles);
void clearsendbuf(channel_t *channles);
void setnonblock(int fd);

//void putsFunction(int clientfd,char *pfilenamebuf,int epollfd,MYSQL * conn, char *username);
//void getsFunction(int clientfd, char * filename,MYSQL * conn, char *username);

int examinePasswd(int clientfd);
void pthreadpollinit(pthreadpoll_t pthreadpoll[]);
void* waitfunc(void* arg);
void dowork(pthreadpoll_t pthreadpoll[],int clientfd,char* filename,char* order,int epfd);
#endif
